@echo off
for /f %%i in (ipconf.txt) do (

rem mkdir
if exist %~dp0target\%%i (
   echo Error: Directory already exists
   rem del /s /q %saveDir%
   goto end
) else (
  mkdir %~dp0target\%%i
)
rem requestFile
openssl genrsa -out %~dp0target\%%i\server.key 2048
openssl req -new -key %~dp0target\%%i\server.key -subj "/C=CN/O=hyt.com/CN=HYT" -out %~dp0target\%%i\server.csr 

rem requestFile->crt No Use CA-> Generate a self signed root certificate:
openssl x509 -req -days 3650 -in %~dp0target\%%i\server.csr  -signkey %~dp0target\%%i\server.key -out %~dp0target\%%i\server.crt -extfile %~dp0\ext.conf -extensions v3_req
rem -extfile %~dp0\ext.conf -extensions v3_req thisok
rem -extensions subjectAltName=DNS:localhost,IP:%%i NOOK
rem -ext subjectAltName=DNS.1:localhost,IP.1:%%i  NOOK
)


:end
pause
